package org.example.web;


import com.example.fanqie.entity.Comment;
import com.example.fanqie.entity.Novel;
import com.example.fanqie.mapper.CommentMapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/comment")
public class commentDao {

    @Resource
    private CommentMapper commentMapper;



//    查询所有
    @RequestMapping("select")
    public List<Comment> selectcomment(  ){

        List<Comment> comments = commentMapper.selectcomment();

        return comments;
    }

    //条件查询
    @RequestMapping("selectlist")
    public List<Comment> selectlist(@RequestBody Comment comment){

        if(comment.getNovelId()!=null && comment.getUserId()!=null && comment.getReply()!=null){
            List<Comment> comments = commentMapper.selectlist01(comment.getNovelId(),comment.getUserId(),comment.getReply());
            return comments;
        }
        List<Comment> comments = commentMapper.selectlist02( comment.getNovelId(),comment.getUserId(),comment.getReply());
        return comments;

    }


}
